package com.oa.action;

import java.util.Calendar;
import java.util.Date;
import java.util.List;

import com.oa.bean.student.Rewardsp;
import com.oa.bean.student.Says;
import com.oa.bean.student.Student;
import com.oa.bean.work.Emp;
import com.oa.service.StudentService;
import com.opensymphony.xwork2.ActionSupport;

public class StudentAction extends ActionSupport{

	private static final long serialVersionUID = 8121368100026937105L;
	
	private StudentService studentService;
	private Student student;
	private List<Student> stulist;
	public void setStudentService(StudentService studentService) {
		this.studentService = studentService;
	}
	public Student getStudent() {
		return student;
	}
	public void setStudent(Student student) {
		this.student = student;
	}
	public List<Student> getStulist() {
		return stulist;
	}
	public void setStulist(List<Student> stulist) {
		this.stulist = stulist;
	}
	
	private Rewardsp rewardsp;
	private Says say;

	public Says getSay() {
		return say;
	}

	public void setSay(Says say) {
		this.say = say;
	}

	public Rewardsp getRewardsp() {
		return rewardsp;
	}

	public void setRewardsp(Rewardsp rewardsp) {
		this.rewardsp = rewardsp;
	}


	//奖惩添加
	public String rewardspAdd(){
		Rewardsp rewardsp = new Rewardsp();
		Student stu = new Student();
		stu.setIntenid(1);
		rewardsp.setStudents(stu);
		rewardsp.setJtitle("好学生");
		rewardsp.setJcontent("三好学生");
		rewardsp.setJdate(new Date());
		Rewardsp r = studentService.rewardspAdd(rewardsp);
		System.out.println(r.toString());
		return SUCCESS;
	}
	
	//奖惩修改
	public String rewardspUpdate(){
		Rewardsp rewardsp = new Rewardsp();
		rewardsp.setJid(1);
		Student stu = new Student();
		stu.setIntenid(1);
		rewardsp.setStudents(stu);
		rewardsp.setJtitle("好学生1");
		rewardsp.setJcontent("三好学生1");
		rewardsp.setJdate(new Date());
		Rewardsp r = studentService.rewardspUpdate(rewardsp);
		System.out.println(r.toString());
		return SUCCESS;
	}
	
	//奖惩删除
	public String rewardspDelete(){
		studentService.rewardspDelete(rewardsp);
		return SUCCESS;
	}
	
	//按奖惩对象查询
	public String rewardspQueryPagerByObject(){
		rewardsp = new Rewardsp();
		Student s = new Student();
		s.setIntenid(1);
		rewardsp.setStudents(s);
		List<Rewardsp> list = studentService.rewardspQueryPagerByObject(0, 1, rewardsp);
		for(Rewardsp r : list){
			System.out.println(r.toString());
		}
		return SUCCESS;
	}
	
	//谈心记录添加
	public String saysAdd(){
		say = new Says();
		Student stu = new Student();
		stu.setIntenid(1);
		say.setStudents(stu);
		Emp e = new Emp();
		e.setEid(1008);
		say.setEmp(e);
		say.setSayscon("神经病");
		say.setSayspro("你有病吗?");
		say.setSysback("呵呵");
		System.out.println(say.toString());
		Says s = studentService.saysAdd(say);
		System.out.println(s.toString());
		return SUCCESS;
	}
	
	//谈心记录修改
	public String saysUpdate(){
		say = new Says();
		say.setSayid(10);
		Student stu = new Student();
		stu.setIntenid(1);
		say.setStudents(stu);
		Emp e = new Emp();
		e.setEid(1001);
		say.setEmp(e);
		say.setSayscon("神经病");
		say.setSayspro("你有病吗?");
		say.setSysback("呵呵");
		Says s = studentService.saysUpdate(say);
		System.out.println(s.toString());
		return SUCCESS;
	}
	
	//谈心记录删除
	public String saysDelete(){
		say = new Says();
		say.setSayid(10);
		studentService.saysDelete(say);
		return SUCCESS;
	}
	
	//谈心记录分页查询
	public String saysQueryPage(){
		say = new Says();
		Student stu = new Student();
		stu.setIntenid(1);
		say.setStudents(stu);
		Emp e = new Emp();
		e.setEid(1001);
		say.setEmp(e);
		say.setSayscon("神");
		List<Says> says = studentService.saysQueryPager(0, 1, say);
		for(Says s : says){
			System.out.println(s.toString());
		}
		return SUCCESS;
	}
	
	public void stuAdd() {
		Student stu = new Student();
		stu.setIntenname("小小明");
		stu.setIntensch("宏图软件");
		stu.setIntensex("男");
		stu.setIntenage(20);
		stu.setIntenhob("打篮球");
		stu.setIntenbir("1996-7-9");
		stu.setIntenfat("小明");
		stu.setIntentel("88888888");
		stu.setIntenfatel("12345678");
		stu.setIntenaddr("浙江杭州");
		stu.setIntenpeo("学校课程体系怎么样?");
		stu.setIntenstatus(1);
		stu.setClassid(1501);
		stu.setHourid(202);
		stu.setIntentime(Calendar.getInstance().getTime());
		studentService.stuSave(stu);
	}
}
